// 路由-相关模块

//1.导入vue路由模块
import VueRouter from 'vue-router'
//2.在vue 中全局注册路由模块,注册后就可以调用<router-view></router-view>
import Vue from 'vue'
Vue.use(VueRouter)


//3.配置路径与组件的映射规则
//引入组件地址
import Layout from '../views/Layout/index.vue'
import Home from '../views/Home/index.vue'
import Search from '../views/Search/index.vue'
import Play from '../views/Play/index.vue'

const routes = [
    { path: '/', redirect: '/layout' },
    {
        path: '/layout', component: Layout,
        redirect: '/layout/home',
        children: [
            {
                path: 'home', component: Home, meta: {// meta保存路由对象额外信息的
                    title: '首页'
                }
            },
            { path: 'search', component: Search, meta: { title: '搜索' } }
        ]
    },
    { path: 'play', component: Play }
]
//4. new 一个路由实例 - 需配置映射规则
const router = new VueRouter({
    routes
})
//5.导出
export default router